﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using CI.Models;
using CI.Models.Production;
using CI.ViewModels.Interfaces;

namespace CI.ViewModels.Industry
{
    public class IndustrySheetOptionsViewModel : ModelBase, IIndustrySheetOptionsViewModel
    {
        private bool _researchTech1Blueprint;
        private int _defaultBlueprintMeLevel;
        private int _defaultBlueprintPeLevel;
        private IJob _defaultUnassignedProductionOutputJob;
        private IJob _defaultMissingProductionInputJob;
        private bool _buyTech2Blueprints;

        private bool _manufactureTech2Components;

        private bool _manufactureTech3Components;

        private bool _manufactureCapitalComponents;

        private bool _manufacturePIComponents;

        private bool _mineMinerals;

        private PIManufacturingLevel _lowestPIManufacturingLevel;

        private IEnumerable<PIManufacturingLevel> _piManufacturingLevels;

        public IndustrySheetOptionsViewModel()
        {
            AllJobs = new ObservableCollection<IJob>();
            StartModel();
            ResearchTech1Blueprints = true;
            BuyTech2Blueprints = true;
            DefaultBlueprintMeLevel = 50;
            DefaultBlueprintPeLevel = 50;
            ManufactureCapitalComponents = true;
            ManufactureTech2Components = true;
            ManufactureTech3Components = true;
            ManufacturePIComponents = true;
            MineMinerals = true;
            LowestPIManufacturingLevel = PIManufacturingLevel.Resource;
            PIManufacturingLevels = new List<PIManufacturingLevel>
                                        {
                                            PIManufacturingLevel.Tier4,
                                            PIManufacturingLevel.Tier3,
                                            PIManufacturingLevel.Tier2,
                                            PIManufacturingLevel.Tier1,
                                            PIManufacturingLevel.Resource
                                        };
            // todo : wire all jobs up from somewhere, intermedary service for industry  jobs?
        }

        public string GroupName { get; set; }

        public bool ResearchTech1Blueprints
        {
            get { return _researchTech1Blueprint; }
            set { SetField(ref _researchTech1Blueprint, value, () => ResearchTech1Blueprints); }
        }

        public bool BuyTech2Blueprints
        {
            get { return _buyTech2Blueprints; }
            set { SetField(ref _buyTech2Blueprints, value, () => BuyTech2Blueprints); }
        }

        public int DefaultBlueprintMeLevel
        {
            get { return _defaultBlueprintMeLevel; }
            set { SetField(ref _defaultBlueprintMeLevel, value, () => DefaultBlueprintMeLevel); }
        }

        public int DefaultBlueprintPeLevel
        {
            get { return _defaultBlueprintPeLevel; }
            set { SetField(ref _defaultBlueprintPeLevel, value, () => DefaultBlueprintPeLevel); }
        }

        public IJob DefaultUnassignedProductionOutputJob
        {
            get { return _defaultUnassignedProductionOutputJob; }
            set { SetField(ref _defaultUnassignedProductionOutputJob, value, () => DefaultUnassignedProductionOutputJob); }
        }

        public IJob DefaultMissingProductionInputJob
        {
            get { return _defaultMissingProductionInputJob; }
            set { SetField(ref _defaultMissingProductionInputJob, value, () => DefaultMissingProductionInputJob); }
        }

        public ObservableCollection<IJob> AllJobs { get; private set; }

        public bool ManufactureTech2Components
        {
            get { return _manufactureTech2Components; }
            set { SetField(ref _manufactureTech2Components, value, () => ManufactureTech2Components); }
        }

        public bool ManufactureTech3Components
        {
            get { return _manufactureTech3Components; }
            set { SetField(ref _manufactureTech3Components, value, () => ManufactureTech3Components); }
        }

        public bool ManufactureCapitalComponents
        {
            get { return _manufactureCapitalComponents; }
            set { SetField(ref _manufactureCapitalComponents, value, () => ManufactureCapitalComponents); }
        }

        public bool ManufacturePIComponents
        {
            get { return _manufacturePIComponents; }
            set { SetField(ref _manufacturePIComponents, value, () => ManufacturePIComponents); }
        }

        public bool MineMinerals
        {
            get { return _mineMinerals; }
            set { SetField(ref _mineMinerals, value, () => MineMinerals); }
        }

        public PIManufacturingLevel LowestPIManufacturingLevel
        {
            get { return _lowestPIManufacturingLevel; }
            set { SetField(ref _lowestPIManufacturingLevel, value, () => LowestPIManufacturingLevel); }
        }

        public IEnumerable<PIManufacturingLevel> PIManufacturingLevels
        {
            get { return _piManufacturingLevels; }
            set { SetField(ref _piManufacturingLevels, value, () => PIManufacturingLevels); }
        }
    }
}